package com.fulin.leetcode;

/**
 * 买卖股票的最佳时机1
 *
 * @Author fulin
 * @Date 2022/9/8 17:37
 **/
public class Num121 {
    public int maxProfit(int[] prices) {
        int min = prices[0];
        int result = 0;

        for (int i = 0; i < prices.length; i++) {
            min = Math.min(min,prices[i]);
            result = Math.max(result,prices[i] - min);
        }

        return result;
    }
}
